<?php /*a:2:{s:68:"/www/wwwroot/jj.xueao400.com/application/wechat/view/keys/index.html";i:1531908558;s:71:"/www/wwwroot/jj.xueao400.com/application/admin/view/public/content.html";i:1531908558;}*/ ?>
<!-- 右则内容区域 开始 -->

<div class="layui-card">
    <!--<?php if(!(empty($title) || (($title instanceof \think\Collection || $title instanceof \think\Paginator ) && $title->isEmpty()))): ?>-->
    <div class="layui-header notselect">
        <div class="pull-left"><span><?php echo htmlentities($title); ?></span></div>
        <div class="pull-right margin-right-15 nowrap">

<!--<?php if(auth("$classuri/add")): ?>-->
<button data-open="<?php echo url('add'); ?>" class='layui-btn layui-btn-sm layui-btn-primary'>添加规则</button>
<!--<?php endif; ?>-->

<!--<?php if(auth("$classuri/del")): ?>-->
<button data-update data-field='delete' data-action='<?php echo url("$classuri/del"); ?>' class='layui-btn layui-btn-sm layui-btn-primary'>删除规则</button>
<!--<?php endif; ?>-->

</div>
    </div>
    <!--<?php endif; ?>-->
    <div class="layui-card-body">
<form onsubmit="return false;" data-auto="true" action="<?php echo request()->url(); ?>" method="post">
    <!--<?php if(empty($list)): ?>-->
    <p class="help-block text-center well">没 有 记 录 哦！</p>
    <!--<?php else: ?>-->
    <input type="hidden" value="resort" name="action"/>
    <table class="layui-table" lay-skin="line">
        <thead>
        <tr>
            <th class='list-table-check-td think-checkbox'>
                <input data-auto-none="" data-check-target='.list-check-box' type='checkbox'/>
            </th>
            <th class='list-table-sort-td'>
                <button type="submit" class="layui-btn layui-btn-normal layui-btn-xs">排 序</button>
            </th>
            <th class="text-left nowrap">关键字</th>
            <th class="text-left nowrap">类型</th>
            <th class="text-left nowrap">预览</th>
            <th class="text-left nowrap">添加时间</th>
            <th class="text-left nowrap">状态</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        <?php foreach($list as $key=>$vo): ?>
        <tr>
            <td class='list-table-check-td think-checkbox'>
                <input class="list-check-box" value='<?php echo htmlentities($vo['id']); ?>' type='checkbox'/>
            </td>
            <td class='list-table-sort-td'>
                <input name="_<?php echo htmlentities($vo['id']); ?>" value="<?php echo htmlentities($vo['sort']); ?>" class="list-sort-input"/>
            </td>
            <td class="text-left nowrap">
                <?php if(!empty($vo['qrc'])): ?><i class="fa fa-qrcode fa-lg pointer" data-tips-image="<?php echo htmlentities($vo['qrc']); ?>" data-tips-text="关键字二维码"></i><?php endif; ?>
                <?php echo htmlentities($vo['keys']); ?>
            </td>
            <td class="text-left nowrap"><?php echo htmlentities($vo['type']); ?></td>
            <td class="text-left nowrap">
                <?php if($vo['type'] == '音乐'): ?>
                <a data-phone-view='<?php echo url("@wechat/review"); ?>?type=music&title=<?php echo htmlentities(urlencode($vo['music_title'])); ?>&desc=<?php echo htmlentities(urlencode($vo['music_desc'])); ?>'>预览 <i class="fa fa-eye"></i></a>
                <?php elseif($vo['type'] == '文字'): ?>
                <a data-phone-view='<?php echo url("@wechat/review"); ?>?type=text&content=<?php echo htmlentities(urlencode($vo['content'])); ?>'>预览 <i class="fa fa-eye"></i></a>
                <?php elseif($vo['type'] == '图片'): ?>
                <a data-phone-view='<?php echo url("@wechat/review"); ?>?type=image&content=<?php echo htmlentities(urlencode($vo['image_url'])); ?>'>预览 <i class="fa fa-eye"></i></a>
                <?php elseif($vo['type'] == '图文'): ?>
                <a data-phone-view='<?php echo url("@wechat/review"); ?>?type=news&content=<?php echo htmlentities($vo['news_id']); ?>'>预览 <i class="fa fa-eye"></i></a>
                <?php elseif($vo['type'] == '视频'): ?>
                <a data-phone-view='<?php echo url("@wechat/review"); ?>?type=video&title=<?php echo htmlentities(urlencode($vo['video_title'])); ?>&desc=<?php echo htmlentities(urlencode($vo['video_desc'])); ?>&url=<?php echo htmlentities(urlencode($vo['video_url'])); ?>'>预览 <i class="fa fa-eye"></i></a>
                <?php else: ?>
                <?php echo htmlentities($vo['content']); endif; ?>
            </td>
            <td class="text-left nowrap"><?php echo htmlentities(format_datetime($vo['create_at'])); ?></td>
            <td class='text-left nowrap'>
                <?php if($vo['status'] == 0): ?><span class="color-desc">已禁用</span><?php elseif($vo['status'] == 1): ?><span class="color-green">使用中</span><?php endif; ?>
            </td>
            <td class='text-left nowrap'>

                <?php if(auth("$classuri/edit")): ?>
                <span class="text-explode">|</span>
                <a data-open='<?php echo url("edit"); ?>?id=<?php echo htmlentities($vo['id']); ?>'>编辑</a>
                <?php endif; if($vo['status'] == 1 and auth("$classuri/forbid")): ?>
                <span class="text-explode">|</span>
                <a data-update="<?php echo htmlentities($vo['id']); ?>" data-field='status' data-value='0' data-action='<?php echo url("$classuri/forbid"); ?>'>禁用</a>
                <?php elseif(auth("$classuri/resume")): ?>
                <span class="text-explode">|</span>
                <a data-update="<?php echo htmlentities($vo['id']); ?>" data-field='status' data-value='1' data-action='<?php echo url("$classuri/resume"); ?>'>启用</a>
                <?php endif; if(auth("$classuri/del")): ?>
                <span class="text-explode">|</span>
                <a data-update="<?php echo htmlentities($vo['id']); ?>" data-field='delete' data-action='<?php echo url("del"); ?>'>删除</a>
                <?php endif; ?>

            </td>
        </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
    <?php if(isset($page)): ?><p><?php echo $page; ?></p><?php endif; ?>
    <!--<?php endif; ?>-->
</form>

</div>
</div>

<script>

    $(function () {
        /**
         * 默认类型事件
         * @type String
         */
        $('body').off('change', 'select[name=type]').on('change', 'select[name=type]', function () {
            var value = $(this).val(), $form = $(this).parents('form');
            var $current = $form.find('[data-keys-type="' + value + '"]').removeClass('hide');
            $form.find('[data-keys-type]').not($current).addClass('hide');
            switch (value) {
                case 'news':
                    return $('[name="news_id"]').trigger('change');
                case 'text':
                    return $('[name="content"]').trigger('change');
                case 'image':
                    return $('[name="image_url"]').trigger('change');
                case 'video':
                    return $('[name="video_url"]').trigger('change');
                case 'music':
                    return $('[name="music_url"]').trigger('change');
                case 'voice':
                    return $('[name="voice_url"]').trigger('change');
            }
        });

        function showReview(params) {
            params = params || {};
            $('#phone-preview').attr('src', '{"@wechat/review"|app_url}&' + $.param(params));
        }

        // 图文显示预览
        $('body').off('change', '[name="news_id"]').on('change', '[name="news_id"]', function () {
            showReview({type: 'news', content: this.value});
        });
        // 文字显示预览
        $('body').off('change', '[name="content"]').on('change', '[name="content"]', function () {
            showReview({type: 'text', content: this.value});
        });
        // 图片显示预览
        $('body').off('change', '[name="image_url"]').on('change', '[name="image_url"]', function () {
            showReview({type: 'image', content: this.value});
        });
        // 音乐显示预览
        var musicSelector = '[name="music_url"],[name="music_title"],[name="music_desc"],[name="music_image"]';
        $('body').off('change', musicSelector).on('change', musicSelector, function () {
            var params = {type: 'music'}, $parent = $(this).parents('form');
            params.title = $parent.find('[name="music_title"]').val();
            params.url = $parent.find('[name="music_url"]').val();
            params.image = $parent.find('[name="music_image"]').val();
            params.desc = $parent.find('[name="music_desc"]').val();
            showReview(params);
        });
        // 视频显示预览
        var videoSelector = '[name="video_title"],[name="video_url"],[name="video_desc"]';
        $('body').off('change', videoSelector).on('change', videoSelector, function () {
            var params = {type: 'video'}, $parent = $(this).parents('form');
            params.title = $parent.find('[name="video_title"]').val();
            params.url = $parent.find('[name="video_url"]').val();
            params.desc = $parent.find('[name="video_desc"]').val();
            showReview(params);
        });

        // 默认事件触发
        $('select[name=type]').map(function () {
            $(this).trigger('change');
        });

        /*! 删除关键字 */
        $('[data-delete]').on('click', function () {
            var id = this.getAttribute('data-delete');
            var url = this.getAttribute('data-action');
            var dialogIndex = $.msg.confirm('确定要删除这条记录吗？', function () {
                $.form.load(url, {id: id}, 'post', function (ret) {
                    if (ret.code === "SUCCESS") {
                        window.location.reload();
                    }
                    $.msg.close(dialogIndex);
                });
            })
        });
    });
</script>

<!-- 右则内容区域 结束 -->